package com.cdut.hwadeefsc.mapper;

import com.cdut.hwadeefsc.entity.attendance;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface attendanceMapper {
    @Select("SELECT * FROM attendance WHERE student_id = #{studentId} ORDER BY event_time DESC")
    List<attendance> findByStudentId(Integer studentId);

    @Select("SELECT * FROM attendance WHERE student_id = #{studentId} AND event_time BETWEEN #{startDate} AND #{endDate}")
    List<attendance> findByStudentIdAndDateRange(@Param("studentId") Integer studentId,
                                                 @Param("startDate") java.util.Date startDate,
                                                 @Param("endDate") java.util.Date endDate);

    @Insert("INSERT INTO attendance (student_id, attendance_date, status, remark, class_id) " +
            "VALUES (#{studentId}, #{attendanceDate}, #{status}, #{remark}, #{classId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(attendance attendance);
}




